<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        //写一个function。清除字符串前后的空格（兼容所有浏览器）
        function trim(str) {
            if (str && typeof str === "string") {
                return str.replace(/(^\$*)|(\$*)$/g, "");
            }
        }
        console.log(trim(" 444 "));
    </script>
</body>

</html>